package com.ham.mud.commands.spells.damage;

import com.ham.mud.characters.MudCharacter;
import com.ham.mud.characters.player.Player;

import java.util.Random;

/**
 * Created by hlucas on Jul 6, 2011 at 10:51:39 AM
 */
public class MagicMissilesSpell extends DamagingSpell {
    public static final Random rand = new Random();

    @Override
    protected String getPlayerText(MudCharacter target, double damage) {
        return "You launch a volley of magic missiles at " + target.getName() + " for " + damage + " damage.";
    }

    @Override
    protected String getOtherPlayerText(String name) {
        return name + " shoots missiles out of his hands.";
    }

    @Override
    protected double getDamageAmount(Player player) {
        int level = player.getLevel();
        int intelligence = player.getStats().getIntelligence();

        int intellDamage = (intelligence - 15) / 2;
        if(intellDamage < 0) {
            intellDamage = 1;
        }
        
        int levelDamage = level / 2 + 1;
        
        return intellDamage*levelDamage*(rand.nextInt(10) + 1);
    }

    @Override
    public int getManaCost() {
        return 5;
    }

    @Override
    public String getName() {
        return "Magic Missiles";
    }
}
